#!/usr/bin/python
#-*- coding: UTF-8 -*-
__author__ = 'bobohb'

from django.db import connection

class IcqDB():

    def query(self,sql,arg):
        """
        执行查询sql
        sql字符串需要替换变量为%s or %d
        arg 为列表
        """
        c = connection.cursor()
        c.execute(sql % arg)
        data = c.fetchall()
        return data


#转换数字
def convert_long(list):
    l = []
    for c in list:
        l.append(int(c[0]))
    return l

#转换日期
def convert_date(list):
    l = []
    for c in list:
        #dt = str(c[0].month)+'/'+str(c[0].day)
        dt = c[0].day
        l.append(dt)
    return l

def convert_full_date(list):
    l = []
    for c in list:
        dt = str(c[0].year)+'-'+str(c[0].month)+'-'+str(c[0].day)
        l.append(dt)
    return l